<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/3nod_web/layui/css/layui.css">
    <script src="/3nod_web/js/echarts.common.min.js"></script>
    <title>生成物料大类退货柱状图</title>
</head>
<body>
<input type="hidden" th:value="${session.suppliedMaterialsCheckWeekReportList}"
       id="suppliedMaterialsCheckWeekReportList"/>
<input type="hidden" th:value="${session.weekList}" id="weekList"/>
<div align="center">
    <h1 id="type" th:text="${type}"></h1>
    <div style="height:400px;width: 1200px;" id="main"></div>
</div>
<script src="/3nod_web/layui/layui.all.js"></script>
<script>
    var myChart = echarts.init(document.getElementById('main'));
    var $ = jquery = layui.jquery;
    $.get("/3nod_web/charts/suppliedMaterialsCheckWeekByUdf8ReportList", function (data) {
        var weekList = data.data.weekList;
        var salesReturnQtyArray = [];
        var type = $("#type").text();
        var suppliedMaterialsCheckMonthReportVoList = data.data.suppliedMaterialsCheckMonthReportVoList;
        console.log(type);
        var j = 0;
        for (var i = 0; i < suppliedMaterialsCheckMonthReportVoList.length; i++) {
            console.log(suppliedMaterialsCheckMonthReportVoList[i].udf8);
            if (suppliedMaterialsCheckMonthReportVoList[i].udf8 == type) {
                salesReturnQtyArray[j] = suppliedMaterialsCheckMonthReportVoList[i].salesReturnQty;
                j++;
            }
        }
        console.log(salesReturnQtyArray);
        var option = {
            xAxis: {
                data: weekList,
                name: '周'
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: salesReturnQtyArray,
                type: 'bar',
                itemStyle: {
                    normal: {
                        label: {
                            show: true,
                            position: 'top',
                            textStyle: {
                                color: '#800080'
                            }
                        }, color: function (params) {
                            var colorList = ['#61a0a8'];
                            return colorList[params.dataIndex]
                        }
                    }
                }

            }]

        };
        myChart.setOption(option);
    });
</script>
</body>
</html>